#include "AnimationSprite.h"
#include "CGlobal.h"
using namespace cocos2d;
CAnimationObject::CAnimationObject( )
{
	
}
CAnimationObject::~CAnimationObject()
{

}

CAnimationObject * CAnimationObject::node(const std::string arrayPic[],int nNum,float delay )
{
	CAnimationObject *pAnimation=new CAnimationObject();
	if (pAnimation)
	{
		pAnimation->autorelease();
		if (pAnimation->init(arrayPic,nNum,delay))
		{
			return pAnimation;
		}
	}
	return NULL;
}

bool CAnimationObject::init(const std::string arrayPic[],int nNum,float delay)
{
	if (!CCAnimation::init())
	{
		return false;
	}

	for(int i=0;i<nNum;i++)
	{

		CCTexture2D *pTexture = CGlobal::TextureWithFile(arrayPic[i].c_str());
		if (pTexture)
		{
			CCRect rect(0,0,pTexture->getContentSize().width,pTexture->getContentSize().height);
			this->addSpriteFrameWithTexture(pTexture,rect)	;
		}
	}
	this->setDelayPerUnit(delay);

	return true;
}

